package com.walnut.lom_system.common.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author walnut
 * @version 1.0
 * @className MybatisPlusConfig
 * @description TODO
 * @date 2022/1/17 16:47
 */
@EnableTransactionManagement
@Configuration
@MapperScan("com.walnut.lom_system.mapper")
@EntityScan("com.walnut.lom_system.entity")
public class MybatisPlusConfig {

    /**
     * 分页插件
     * @return 分页插件拦截
     */
    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.H2));
        return interceptor;
    }

}
